<?php
class TaskUtils {

	function isExpertTask(&$bean) {
		
		$expert_task_type = array (
		"FirstEdit",
		"ClarificationEdit",
		"Rewriting",
		"ExpertScientificReview",
		"JournalSelection",
		"CoverLetterDevelopment",
		"AbstractDevelopment",
		"ReviewerRecommendation",
		"JournalManagementAndSubmission",
		"Writing",
	);
		
		if (isset($bean->type) and in_array($bean->type,$expert_task_type)) {
			return true;
		} else {
			return false;
		}
	}
	
	function isAssignmentNeededTask(&$bean) {
		
		$assignment_needed_task_type = array (
			"InternalReview",
			"FirstEdit",
			"ClarificationEdit",
			"Rewriting",
			"ExpertScientificReview",
			"ESRReview",
			"JournalSelection",
			"JSReview",
			"CoverLetterDevelopment",
			"CLDReview",
			"AbstractDevelopment",
			"ADReview",
			"ReviewerRecommendation",
			"RRReview",
			"JournalManagementAndSubmission",
			"Writing",
		);
		
		if (isset($bean->type) and in_array($bean->type,$assignment_needed_task_type)) {
			return true;
		} else {
			return false;
		}
	}

	function dueDefault($deliverable_id,$group_time_zone) {
		global $timedate, $current_user;
		$deliverable = new edanz_Deliverables();
		$deliverable->retrieve($deliverable_id);
		/**
		 * Date element of the datetime taken from the related deliverable�s client due date
		 */
		$datepart = $timedate->getDatePart($deliverable->date_due);

		/**
		 * Time element will be 12pm for deliverables at the �Express� or �Subexpress� speed, otherwise 2pm.
		 */
		if ($deliverable->speed == "express" or $deliverable->speed == "subexpress")
			$timepart = "12:00:00";
		else
			$timepart = "14:00:00";
		
		// new due date
		$date_due = $datepart." ".$timepart;
		$date_due_db = date("Y-m-d H:i:s",strtotime($date_due));
		if(!empty($group_time_zone)){
			$group_GMT = $date_due_db." - ".$group_time_zone." hour";
	 		$date_due = date("Y-m-d H:i:s",strtotime($group_GMT));
		}
		return $date_due;
		
	}

}
?>
